Support NullMarked and NullUnmarked Annotations - #26559
Conversation
Co-authored-by: TheDrawingCoder-Gamer <TheDrawingCoder-Gamer@users.noreply.github.com>
noti0na1
left a comment
There was a problem hiding this comment.
The core change looks good to me. The test suit need to be extended for:
- sub packages;
- a jar, if possible;
- generics;
- a package marked by both annotations.
| * `@NullUnmarked` re-enables the implicit-nulls default. | ||
| */ | ||
| private def isNullMarked(sym: Symbol)(using Context): Boolean = | ||
| sym.ownersIterator.map(ownerNullMarking).collectFirst { case Some(marked) => marked }.getOrElse(false) |
There was a problem hiding this comment.
According to the document (https://jspecify.dev/docs/api/org/jspecify/annotations/NullMarked.html):
@NullMarkedand@NullUnmarked... To apply these annotations to an entire (single) package, create a package-info.java file and annotate the package declaration there. This annotation has no effect on "subpackages".
We may want to stop the iteration at package level.
| * classes). For all other owners we use `unforcedAnnotation` to avoid forcing symbols that may | ||
| * still be under construction during classfile loading / unpickling. | ||
| */ | ||
| private def ownerNullMarking(owner: Symbol)(using Context): Option[Boolean] = |
There was a problem hiding this comment.
Do we want to also handle module-info?
| * @param state mutable nullification state tracking the current mode for the result type | ||
| * (`resultTypeMode`) and the current nesting level (`currentTypeMode`). | ||
| */ | ||
| private class ImplicitNullMap( |
There was a problem hiding this comment.
I saw the spec has some special rules for wildcards and type parameters. Are they supported by this PR? If not, I'm not sure if we want to support them?
Based on #26456
Adds support for NullMarked and NullUnmarked. Inside Java source, symbols with NullMarked in scope will be non-null, and NullUnmarked scopes remain implicit.
Have you relied on LLM-based tools in this contribution?
Yes, and I checked the output by hand and writing the corresponding tests.
How was the solution tested?
New automated tests